<?php
abstract class inputoption extends htmlinput {
	public $displayvalue;
	public $checked = false;
	
	public function __construct(){
		$this->validAttributes[] = 'onclick';
		$this->validAttributes[] = 'onfocus';
		$this->validAttributes[] = 'onchange';
		$this->validAttributes[] = 'value';
	}

	public function __toString(){		
		if( ! in_array('id', array_keys($this->attributes))){
			$this->attributes['id'] = $this->randomstring(8);
		}
		$this->html = '<label for="' . $this->attributes['id'] . '">';
		$this->html .= '<input type="' . $this->tag . '"';

		foreach ( $this->attributes as $key => $value){
			if ( ! empty($value) || strlen($value)){
				$this->html .= ' ' . $key . '="' . $value . '"';
			}
		}
		if ( $this->checked ){
			$this->html .= ' checked';
		}
		//add closing tag
		$this->html .=  ">";
		$this->html .= $this->displayvalue;
		$this->html .= '</label>';
		return $this->html;
	}

	public function check(){
		$this->checked = true;	
	}
	
	public function uncheck(){
		$this->checked = false;
	}

	public function ischecked(){
		return $this->checked;
	}
	
	public function setDisplayValue($value){
		$this->displayvalue = $value;
	}
}
?>